home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 50
/
Volume 50 - JOGO DISK .iso
/
Games
/
lagoonquest.swf
/
scripts
/
frame_21
/
DoAction.as
Wrap
Text File
|
2007-09-27
|
20KB
|
731 lines
function updateAction()
{
keyLeft = Key.isDown(37);
keyRight = Key.isDown(39);
keyup = Key.isDown(38);
keydown = Key.isDown(40);
if(dolphinchar.state != "splash")
{
if(keyRight)
{
speed += trust;
if(!keyup && !keydown && dolphinchar.state != "hit")
{
dolphinchar.gotoAndStop("swim");
}
}
if(keyLeft)
{
speed -= trust2;
}
speed *= decay;
dolphinchar._x = Math.round(initX + speed * 9);
if(keyup)
{
if(dolphinchar.state != "hit")
{
dolphinchar.gotoAndStop("monte");
}
if(hspeed > 0)
{
hspeed *= hdecay;
}
hspeed -= htrust;
}
if(keydown)
{
if(dolphinchar.state != "hit")
{
dolphinchar.gotoAndStop("plonge");
}
if(hspeed < 0)
{
hspeed *= hdecay;
}
hspeed += htrust;
}
if(!keyup && !keydown)
{
hspeed *= hdecay2;
if(!keyRight && !keyLeft && dolphinchar.state != "hit")
{
speed >= 3 ? dolphinchar.gotoAndStop("slow") : dolphinchar.gotoAndStop("idle");
}
}
if(y < 75)
{
!(hspeed < -2.5 && animJumpAvlbl) ? (hspeed = 3) : dolphinchar.gotoAndStop("splash");
}
y += hspeed;
dolphinchar._y = y;
}
if(pearlActivated)
{
pearlTimer--;
if(pearlTimer <= 0)
{
pearlActivated = false;
pearlTimer = 180;
trust = 0.7;
}
}
drawFront();
drawBack();
checkUpcomingEvents();
}
function checkHitOnHitzone(newHitzone)
{
if(newHitzone.hitTest(dolphinchar.hitzone) && dolphinchar.state != "hit")
{
dolphinchar.gotoAndStop("hit");
lifeMeter.meter.nextFrame();
}
}
function sendPearl()
{
pearlType = ++pearlType % 2;
pearl.gotoAndStop(pearlType + 2);
pearl.pearl.gotoAndPlay(1);
pearl._x = 525;
pearl._y = 85 + random(50);
}
function checkPearl()
{
adjustElementSpeed(pearl);
if(pearl.hitTest(dolphinchar.hitzone) && pearl.pearl._currentframe < 24)
{
if(pearlType == 0)
{
fx.gotoAndPlay("pearl");
trust = 1.1;
lifeMeter.score += 500;
}
else
{
fx.gotoAndPlay("pearlBad");
trust = 0.3;
lifeMeter.score -= 500;
}
pearlActivated = true;
pearl.pearl.gotoAndPlay("die");
}
}
function checkMeduseAI()
{
adjustElementSpeed(enemyContainOvr);
var i = 1;
while(i < 4)
{
var eTarget = eval("enemyContainOvr.meduse.md" + i);
var toMoveX = eTarget.xToMove - eTarget._x;
if(toMoveX < -5 || toMoveX > 5)
{
eTarget._x += toMoveX / 5;
}
else
{
eTarget.xToMove = Math.round(eTarget._x + random(50) - 30);
}
var toMoveY = eTarget.yToMove - eTarget._y;
if(toMoveY < -5 || toMoveY > 5)
{
eTarget._y <= -25 ? (eTarget.yToMove += 25) : (eTarget._y += toMoveY / 10);
}
else
{
eTarget.yToMove = Math.round(eTarget._y + random(30) - 15);
}
checkHitOnHitzone(eTarget);
i++;
}
}
function checkPufferAI()
{
adjustElementSpeed(enemyContainOvr);
var i = 1;
while(i < 9)
{
var eTarget = eval("enemyContainOvr.puffer.puffer" + i);
checkHitOnHitzone(eTarget);
i++;
}
}
function checkOil()
{
adjustElementSpeed(enemyContainOvr);
if(enemyContainOvr.oil.hitzone.hitTest(dolphinchar._x,dolphinchar._y,true))
{
oilTimer--;
speed *= 0.6;
hspeed *= 0.6;
if(oilTimer <= 0 && dolphinchar.state != "hit")
{
oilTimer = 45;
dolphinchar.gotoAndStop("hit");
lifeMeter.meter.nextFrame();
}
}
}
function checkFishingBoat()
{
adjustElementSpeed(enemyContain);
var i = 1;
while(i < 4)
{
var eTarget = eval("enemyContain.fishing.fishman" + i);
checkHitOnHitzone(eTarget.lure);
checkHitOnHitzone(eTarget.line);
i++;
}
}
function checkGiantBoat()
{
adjustElementSpeed(enemyContainOvr);
var _loc1_ = enemyContainOvr.giantBoat;
if(_loc1_.helix.hitzone.hitTest(dolphinchar.hitzone) || _loc1_.hitzone1.hitTest(dolphinchar.hitzone))
{
if(dolphinchar.state != "hit")
{
dolphinchar.gotoAndStop("hit");
lifeMeter.health.nextFrame();
}
speed -= 0.8;
}
if(_loc1_.hitzone2.hitTest(dolphinchar.hitzone))
{
dolphinchar.gotoAndStop("hit");
lifeMeter.health.nextFrame();
hspeed = 3;
}
}
function checkBuoysJump()
{
var _loc1_ = new Object();
_loc1_.x = spawnPntFgnd.spawnPoint._x;
_loc1_.y = spawnPntFgnd.spawnPoint._y;
spawnPntFgnd.localToGlobal(_loc1_);
enemyContain._x = _loc1_.x;
enemyContain._y = _loc1_.y;
buoysOver1._x = enemyContain._x + enemyContain.buoysJump.front._x;
buoysOver1._y = enemyContain._y + enemyContain.buoysJump.front._y;
if(enemyContain.buoysJump.hitzone.hitTest(dolphinchar))
{
if(enemyContain.buoysJump.sparkle._currentframe == 1)
{
lifeMeter.score += 5685;
enemyContain.buoysJump.sparkle.gotoAndPlay(2);
}
}
}
function checkBuoys()
{
adjustElementSpeed(enemyContain);
var j = 0;
for(var i in enemyContain.buoys)
{
j++;
var buoyVar = eval("enemyContain.buoys.buoys" + j);
var buoyOverVar = eval("buoysOver" + j);
buoyOverVar._x = enemyContain._x + buoyVar._x + buoyVar.front._x;
buoyOverVar._y = enemyContain._y + buoyVar._y + buoyVar.front._y;
if(dolphinchar.hitzone.hitTest(buoyVar.hitzone1) || dolphinchar.hitTest(buoyVar.hitzone2))
{
speed -= 0.8;
}
if(dolphinchar.hitzone.hitTest(buoyVar.hitzone3))
{
if(buoyVar.sparkle._currentframe == 1)
{
lifeMeter.score += 4859;
buoyVar.sparkle.gotoAndPlay(2);
}
}
if(bossShark.hitzone.hitTest(buoyVar.hitzone3))
{
buoyOverVar._visible = buoyVar._visible = false;
bossShark.gotoAndStop("jammed");
}
}
}
function resetBuoys()
{
var j = 0;
for(var i in enemyContain.buoys)
{
j++;
var buoyVar = eval("enemyContain.buoys.buoys" + j);
var buoyOverVar = eval("buoysOver" + j);
buoyOverVar._visible = buoyVar._visible = true;
}
}
function checkBossSharkAI()
{
if(bossShark.state != "jammed")
{
var _loc1_ = Math.round((dolphinchar._y - bossShark._y) / 15);
bossShark._y += _loc1_;
bossShark._x += bossSharkSpeed;
if(bossShark._x > 120)
{
bossSharkSpeed = -1.6;
}
else if(bossShark._x < 40)
{
bossSharkSpeed = 1.6;
}
if(bossAtckFreq < 120)
{
bossAtckFreq++;
}
else if(bossShark.state != "attack" && bossSharkActive)
{
bossAtckFreq = 0;
bossShark.gotoAndPlay("attack");
}
checkHitOnHitzone(bossShark);
}
else
{
adjustElementSpeed(bossShark);
}
}
function checkOursins()
{
adjustElementSpeed(oursins);
if(oursins._x > -400)
{
var i = 1;
while(i < 5)
{
var eTarget = eval("oursins.oursin" + i);
checkHitOnHitzone(eTarget.oursin);
checkHitOnHitzone(eTarget.oursin.spike1);
checkHitOnHitzone(eTarget.oursin.spike2);
checkHitOnHitzone(eTarget.oursin.spike3);
i++;
}
}
else
{
muteOursins();
}
}
function sendOursins()
{
oursins._x = 600;
var i = 1;
while(i < 5)
{
var eTarget = eval("oursins.oursin" + i);
var frameRandom = random(15) + 2;
eTarget.gotoAndPlay(frameRandom);
i++;
}
}
function muteOursins()
{
var i = 1;
while(i < 5)
{
var eTarget = eval("oursins.oursin" + i);
eTarget.gotoAndStop(1);
i++;
}
}
function sendEnemyContain(container, enemyToSend, height)
{
var newContainer = eval(container);
newContainer._x = 600;
newContainer._y = height;
newContainer.gotoAndStop(enemyToSend);
}
function adjustElementSpeed(element)
{
if(speed >= 0)
{
element._x -= speed;
}
}
function drawBack()
{
if(speed >= 0)
{
back.back._x -= speed / 5;
}
for(var i in backArray)
{
var targetBack = eval(backArray[i]);
var xDist = back.back._x + targetBack._x - dolphinchar._x;
if(xDist < -950)
{
var targetBack2 = i != 1 ? eval(back.back.bg2) : eval(back.back.bg1);
targetBack._x = targetBack2._width + targetBack2._x - 20;
}
}
}
function drawFront()
{
adjustElementSpeed(front);
for(var i in fgndArray)
{
var targetFgnd = eval(fgndArray[i]);
if(targetFgnd.fgnd.hitTest(dolphinchar._x,dolphinchar._y,true) && dolphinchar.state != "splash" && dolphinchar.state != "hit")
{
dolphinchar.gotoAndStop("hit");
lifeMeter.meter.nextFrame();
speed -= 0.8;
hspeed = -3;
}
var xDist = front._x + targetFgnd._x - dolphinchar._x;
if(xDist < -750)
{
var targetFgnd2 = i != 1 ? eval(front.fgnd_2) : eval(front.fgnd_1);
targetFgnd._x = targetFgnd2._width + targetFgnd2._x - 10;
if(changeInFgnd)
{
if(spawnPntFgnd == undefined)
{
spawnPntFgnd = targetFgnd;
targetFgnd.gotoAndStop(fgndToShow);
changeInFgnd = false;
}
else if(targetFgnd == spawnPntFgnd)
{
spawnPntFgnd.gotoAndStop(1);
delete spawnPntFgnd;
delete fgndToShow;
changeInFgnd = false;
}
}
}
}
}
function checkUpcomingEvents()
{
var _loc1_ = levelArray[0];
switch(_loc1_)
{
case "start":
sendEnemyContain("enemyContain","borneStart",50);
levelArray.shift();
break;
case "borneStart":
adjustElementSpeed(enemyContain);
if(enemyContain._x < -300)
{
bossShark.gotoAndPlay("intro");
sendEnemyContain("enemyContainOvr","meduse",150);
levelArray.shift();
}
break;
case "meduse":
checkBossSharkAI();
checkMeduseAI();
if(enemyContainOvr._x < -600)
{
sendPearl();
sendEnemyContain("enemyContainOvr","puffer",120);
levelArray.shift();
}
break;
case "puffer":
checkPearl();
checkBossSharkAI();
checkPufferAI();
if(enemyContainOvr._x < -600)
{
bossSharkActive = false;
sendEnemyContain("enemyContain","buoys",175);
levelArray.shift();
}
break;
case "buoys":
checkPearl();
checkBossSharkAI();
checkBuoys();
if(enemyContain._x < -300)
{
bossShark.state = "jammed";
sendOursins();
changeInFgnd = true;
fgndToShow = 2;
resetBuoys();
levelArray.shift();
}
break;
case "waitForChange":
checkBossSharkAI();
checkOursins();
if(!changeInFgnd)
{
bossShark._visible = false;
sendEnemyContain("enemyContain","buoysJump",50);
levelArray.shift();
}
break;
case "buoysJump":
checkBossSharkAI();
checkBuoysJump();
checkOursins();
changeInFgnd = true;
if(spawnPntFgnd == undefined)
{
changeInFgnd = false;
sendEnemyContain("enemyContain","fishingBoat",80);
levelArray.shift();
}
break;
case "fishingBoat":
checkFishingBoat();
if(enemyContain._x < -500)
{
animJumpAvlbl = false;
sendEnemyContain("enemyContainOvr","giantBoat",100);
levelArray.shift();
}
break;
case "giantBoat":
checkGiantBoat();
if(enemyContainOvr._x < -700)
{
animJumpAvlbl = _loc0_ = true;
bossShark._visible = _loc0_;
sendEnemyContain("enemyContainOvr","oil",110);
levelArray.shift();
}
break;
case "oil":
checkOil();
if(enemyContainOvr._x < -600)
{
sendPearl();
bossSharkActive = true;
bossShark._x = 100;
bossAtckFreq = 0;
bossShark.gotoAndPlay("intro");
sendEnemyContain("enemyContain","fishingBoat",80);
levelArray.shift();
}
break;
case "fishingBoat2":
checkPearl();
checkBossSharkAI();
checkFishingBoat();
if(enemyContain._x < -500)
{
sendEnemyContain("enemyContainOvr","puffer",150);
levelArray.shift();
}
break;
case "puffer2":
checkPearl();
checkBossSharkAI();
checkPufferAI();
if(enemyContainOvr._x < -600)
{
sendOursins();
sendEnemyContain("enemyContainOvr","meduse",150);
levelArray.shift();
}
break;
case "meduse2":
checkBossSharkAI();
checkMeduseAI();
checkOursins();
if(enemyContainOvr._x < -500)
{
bossSharkActive = false;
sendEnemyContain("enemyContain","buoys",150);
levelArray.shift();
}
break;
case "buoys2":
checkBossSharkAI();
checkBuoys();
checkOursins();
if(enemyContain._x < -300)
{
resetBuoys();
bossShark.state = "jammed";
changeInFgnd = true;
fgndToShow = 3;
levelArray.shift();
}
break;
case "waitForChange2":
checkOursins();
if(!changeInFgnd)
{
sendEnemyContain("enemyContain","buoysJump",50);
levelArray.shift();
}
break;
case "buoysJump2":
checkBuoysJump();
changeInFgnd = true;
if(spawnPntFgnd == undefined)
{
changeInFgnd = false;
sendEnemyContain("enemyContainOvr","puffer",150);
levelArray.shift();
}
break;
case "puffer3":
checkPufferAI();
if(enemyContainOvr._x < -600)
{
animJumpAvlbl = false;
sendEnemyContain("enemyContainOvr","giantBoat",100);
levelArray.shift();
}
break;
case "giantBoat2":
checkGiantBoat();
if(enemyContainOvr._x < -700)
{
animJumpAvlbl = true;
sendEnemyContain("enemyContain","fishingBoat",80);
sendEnemyContain("enemyContainOvr","oil",110);
levelArray.shift();
}
break;
case "oil2":
checkOil();
checkFishingBoat();
if(enemyContainOvr._x < -600)
{
sendEnemyContain("enemyContainOvr","meduse",150);
levelArray.shift();
}
break;
case "meduse3":
checkMeduseAI();
if(enemyContainOvr._x < -600)
{
sendOursins();
changeInFgnd = true;
fgndToShow = 2;
levelArray.shift();
}
break;
case "waitForChange3":
checkOursins();
if(!changeInFgnd)
{
sendEnemyContain("enemyContain","buoysJump",50);
levelArray.shift();
}
break;
case "buoysJump3":
checkOursins();
checkBuoysJump();
changeInFgnd = true;
if(spawnPntFgnd == undefined)
{
changeInFgnd = false;
sendEnemyContain("enemyContain","fishingBoat",80);
sendEnemyContain("enemyContainOvr","puffer",150);
levelArray.shift();
}
break;
case "puffer4":
checkFishingBoat();
checkPufferAI();
if(enemyContainOvr._x < -600)
{
sendOursins();
changeInFgnd = true;
fgndToShow = 3;
levelArray.shift();
}
break;
case "waitForChange4":
checkOursins();
if(!changeInFgnd)
{
sendEnemyContain("enemyContain","buoysJump",50);
levelArray.shift();
}
break;
case "buoysJump4":
checkOursins();
checkBuoysJump();
changeInFgnd = true;
if(spawnPntFgnd == undefined)
{
sendPearl();
changeInFgnd = false;
bossShark.gotoAndPlay("intro");
sendEnemyContain("enemyContainOvr","meduse",150);
levelArray.shift();
}
break;
case "meduse5":
checkPearl();
checkBossSharkAI();
checkMeduseAI();
if(enemyContainOvr._x < -600)
{
sendEnemyContain("enemyContain","fishingBoat",80);
sendEnemyContain("enemyContainOvr","puffer",120);
levelArray.shift();
}
break;
case "puffer5":
checkPearl();
checkBossSharkAI();
checkFishingBoat();
checkPufferAI();
if(enemyContainOvr._x < -600)
{
sendEnemyContain("enemyContain","buoys2",175);
levelArray.shift();
}
break;
case "buoys3":
checkBossSharkAI();
checkBuoys();
if(enemyContain._x < -300)
{
sendOursins();
resetBuoys();
bossShark.state = "jammed";
changeInFgnd = true;
fgndToShow = 2;
levelArray.shift();
}
break;
case "waitForChange5":
checkBossSharkAI();
checkOursins();
if(!changeInFgnd)
{
sendEnemyContain("enemyContain","buoysJump",50);
levelArray.shift();
}
break;
case "buoysJump5":
checkBossSharkAI();
checkBuoysJump();
checkOursins();
changeInFgnd = true;
if(spawnPntFgnd == undefined)
{
changeInFgnd = false;
sendEnemyContain("enemyContain","borneEnd",50);
levelArray.shift();
}
break;
case "borneEnd":
adjustElementSpeed(enemyContain);
if(enemyContain._x < -300)
{
finalScore = lifeMeter.score;
dolphinchar.gotoAndStop("victory");
}
}
}
_global.dolphinGame = this;
_quality = "MEDIUM";
_focusrect = false;